package cn.cpf.beantest;

import org.aspectj.lang.annotation.Before;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

public class MyBeanPostProcessor implements BeanPostProcessor {
    @Override
    public Object postProcessBeforeInitialization(Object o, String s) throws BeansException {
        if (o instanceof Teacher) {
            ((Teacher) o).setPhone(29384343);
        }
        if (o instanceof Person) {
            ((Person) o).setPhone(11112222);
        }
        return o;
    }

    @Override
    @Before("")
    public Object postProcessAfterInitialization(Object o, String s) throws BeansException {
        return o;
    }
}
